package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author stone
 * @date 2022/07/11 16:28
 */
@RequestMapping("header")
@Controller
public class HeaderLimitController {

    //localhost:8080/header/limit
    // 既要携带abc，也要携带def请求头
    @RequestMapping(value = "limit",headers = {"abc","def"})
    @ResponseBody
    public BaseRespVo headerLimit() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData("Header limit");
        return baseRespVo;
    }

    // 这两个属性（consumes\produces）都是可以接收多个值的，多个值之间的关系是or
    // Content-Type和Accept这两个请求头的值的格式是固定：*/*
    @RequestMapping(value = "consumes", consumes = "abc/def")
    @ResponseBody
    public BaseRespVo consumes() {
        return BaseRespVo.ok("Content-Type的值限定为abc/def");
    }

    //@RequestMapping(value = "accept", produces = "def/abc")
    @RequestMapping(value = "accept", produces = "application/json")
    @ResponseBody //Accept:application/json
    public BaseRespVo produces() {
        return BaseRespVo.ok("Accept的值限定为def/abc");
    }
}
